package com.lagou.server;

import com.lagou.model.UserMessage;

import java.io.IOException;

/**
 * 服务器的主功能
 */
public class ServerView {

    private ServerInitClose sic;
    private ServerDao sd;

    public ServerView(ServerInitClose sic,ServerDao sd) {
        this.sic = sic;
        this.sd = sd;
    }

    public void serverReceive() throws IOException, ClassNotFoundException {
        UserMessage um = (UserMessage) sic.getOis().readObject();
        System.out.println("接收到的消息是：" + um);
        if (sd.serverManagerCheck(um.getUser())) {
            um.setType("success");
        }else{
            um.setType("fail");
        }

        sic.getOos().writeObject(um);
        System.out.println("服务器发送校验结果成功");
    }
}
